#version 330 core
in vec2 TexCoord;
out vec4 FragColor;
uniform sampler2D textureSampler;
uniform vec4 tint;
void main() {
    vec2 shadowOffset = vec2(0.006, -0.006);

    // 采样阴影
    vec4 shadow = texture(textureSampler, TexCoord - shadowOffset);

    // 采样主纹理
    vec4 color = texture(textureSampler, TexCoord);

    // 如果完全透明则丢弃
    if(color.a < 0.01 && shadow.a < 0.01) {
        discard;
    }

    // 先绘制阴影(黑色)
    vec4 result = vec4(0.3, 0.3, 0.3, 1.0);

    color.rgb = vec3(0.975, 0.975, 0.975);
    color.rgb *= tint.rgb;
    // 再叠加主纹理颜色
    result = mix(result, color, color.a);

    vec3 tintedColor = color.rgb * tint.rgb;

    FragColor = result;
}